/**
 * Created by Administrator on 2017/1/16.
 */


//构造函数

function Ball(options) {
    this._init(options);
}

//原型函数
Ball.prototype = {
    constructor:Ball,
    _init:function (options) {
        this.x = options.x || 0
        this.y = options.y || 0;
        this.r = options.r || 0;
        this.fill = options.fill || 'red';
        this.speed = options.speed || 0;
    },
    //创建小球
    render:function (ctx) {
        ctx.beginPath();
        ctx.fillStyle = this.fill;
        ctx.arc(this.x,this.y,this.r,0,2*Math.PI,true);
        ctx.fill();
    },
    //更新数据,主要目的是使得小球可以运动
    update:function () {
        this.x+=this.speed;
    }

};